<template>
	<view class="container">
		<navbar></navbar>
		<view class="main">
			<view class="close_btn" v-if="!is_stop" @click="close">
				关闭续费
			</view>
			<view class="close_btn" v-else @click="open">
				开启续费
			</view>
			<view class="main_box">
				<view class="price_box">
					<view class="price">
						10
					</view>
					<view class="">
						元/月
					</view>
				</view>
				<view class="time">
					有效期：{{end_date_h}}
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import navbar from "@/components/navbar/navbar";
	export default {
		data() {
			return {
				end_date_h: '',
				is_stop: 1
			}
		},
		onShow() {
			app._get('user/getlianLianWithholdInfo', {}, (res) => {
				this.end_date_h = res.data.end_date_h
				this.is_stop = res.data.is_stop
			});
		},
		methods: {
			close(){
				let _this = this
				uni.showModal({
					content: '是否关闭连连钱包',
					success: function(res) {
						if(res.confirm){
							app._post_form('user/lianLianWithholdOut', {}, (res) => {
								uni.showModal({
									content: res.msg,
									showCancel: false
								})
							},null, function() {
								// 解除按钮禁用
								app._get('user/getlianLianWithholdInfo', {}, (res) => {
									_this.end_date_h = res.data.end_date_h
									_this.is_stop = res.data.is_stop
								});
							});
						}
					}
				})
				
			},
			open(){
				uni.showModal({
					content: '是否开通?',
					showCancel: true,
					cancelText: '我再想想',
					confirmText: '去开通',
					success: function (res) {
						if (res.confirm) {
							app._post_form('user/getLianLianWithhold', {}, function(result) {
								console.log(result)
								if (1 == result.code) {
									app.navigationTo(result.data.gateway_url)
								}else{
									app.showError(result.data.msg);
								}
							}, null, function() {
								// 解除按钮禁用
								app.showError(result.msg);
							});
						} 
						
					}
				})
				
			},
		}
	}
</script>

<style lang="scss">
	.container{
		/* margin: 0 auto; */
	}
	.main{
		display: flex;
		justify-content: center;
		/* align-items: center; */
		width: 100%;
		min-height: 100vh;
		height: 2000rpx;
		background: url('https://img.btcys.com/btcys/20230415135654138932764.png')  no-repeat;
		background-size: 750rpx 100%;
	}
	.close_btn{
		position: absolute;
		right: 100rpx;
		top: 50rpx;
		color: #eeeeee;
		border: #e1b222 1rpx solid;
		padding: 10rpx;
		border-radius: 50rpx;
		font-size: 24rpx;
		z-index: 999;
	}
	.main_box{
		color: #DEBB77;
		display: flex;
		flex-direction: column;
		height: 100rpx;
		align-items: center;
		.price_box{
			display: flex;
			flex-direction: row;
			align-items: end;
			margin-top: 50rpx;
			.price{
				position: relative;
				top: 20rpx;
				font-size: 80rpx;
			}
		}
		.time{
			margin-top: 20rpx;
		}
	}
	
</style>
